/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    isEnabled: { type: 'boolean' },
    name: {  type: 'string', _type: 'string',inputType: 'input', title: '名称',  enableArea: [ 'table', 'input', 'detail', 'search'],  required:true},
    // address: {
    //   type: 'string', inputType: 'input', title: '地址', enableArea: [
    //     'detail', 'input',
    //   ],
    // },
    contacts: {
      type: Array,  _type: 'array',inputType: 'input', title: '联系人列表', enableArea: [
        'detail', 'input',
      ],
    },

    vendorType: {
      type: 'string',  _type: 'select',inputType: 'select', title: '供应商类型', enableArea: [
        'detail', 'input','table'
      ],
      options: [
        '经销代理',
        '生产商'
      ]
    },
    materialType: {
      type: 'string',  _type: 'select',inputType: 'select', title: '材料类型', enableArea: [
        'detail', 'input','table'
      ],
      options: [
        '主营业务采购',
        '其它采购'
      ]
    },
    materials: {  type: 'string', _type: 'string',inputType: 'input', title: '供应商品',  enableArea: [ 'table', 'input', 'detail', 'search']},
    fileList: {
      type: 'array', _type: 'array', title: 'PIC附件', enableArea: []
    },
    pdfFileList: {
      type: 'array', _type: 'array', title: 'PDF', enableArea: []
    },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  _schema.index({'code':1});
  return connect.model('Vendor', _schema);
};
/**
 current: { type: 'number' },
 voltage: { type: 'number' },
 activePower: { type: 'number' },
 positiveActiveEnergy: { type: 'number' },
 ReverseActiveEnergy: { type: 'number' },
 currentA: { type: 'number' },
 currentB: { type: 'number' },
 currentC: { type: 'number' },
 voltageA: { type: 'number' },
 voltageB: { type: 'number' },
 voltageC: { type: 'number' },
 */
